package cn.jzq.kotoba.modules.designpattern.observer.weather;

import lombok.Data;
import lombok.ToString;

/**
 * @author jzq
 * @date 2018/12/19 14:16
 */
@Data
@ToString
public class CurrentConditionsDisplay implements Observer, DisplayElment{
    private Double temperature;

    private Double humidity;

    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObject(this);
    }

    @Override
    public void display() {
        System.out.println("current conditions: " + this.temperature + " C degrees and " + humidity + "% humidity" );
    }

    @Override
    public void update(double temp, double humidity, double pressure) {
        System.out.println("update ~");
        this.temperature = temp;
        this.humidity = humidity;
        display();
    }

}
